package com.jia.area.controller;

import com.jia.area.service.AreaShopService;
import com.jia.shop.entity.Shop;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author jia
 */
@RestController
@RequestMapping("/area")
public class AreaShopController {

    @Resource
    private AreaShopService areaShopService;

    /**
     * 依据商店类型和地区查询商店
     *
     * @param shopTypeId 类型id
     * @param distance   距离
     * @param longitude  经度
     * @param latitude   维度
     * @return 分页对象
     */
    @GetMapping("/shop/list/{shopTypeId}")
    public ResponseEntity<List<Shop>> distanceShopList(@PathVariable Long shopTypeId,
                                                       @RequestParam Integer current,
                                                       @RequestParam(required = false) Long distance,
                                                       @RequestParam(required = false) Double longitude,
                                                       @RequestParam(required = false) Double latitude) {
        return ResponseEntity.ok(this.areaShopService.distanceShopList(shopTypeId, current, distance, longitude, latitude));
    }

}
